home *** CD-ROM | disk | FTP | other *** search
/ Delphi Developer's Kit 1996 / Delphi Developer's Kit 1996.iso / power / source2 / main.pas < prev   
Pascal/Delphi Source File  |  1995-12-22  |  3KB  |  122 lines

  1. { Questo file puo essere distribuito e modificato liberamente
  2.  
  3.   Spero diverta voi quanto mi sono divertito io nel farlo
  4.  
  5.   Paolo Codiga
  6.   Via St Antonio 14
  7.   CH-6596 Gordola
  8.   Svizzera
  9.   Paolo_Codiga@MSN.COM
  10.  
  11.   Tel ++41 93 67.63.56    ++41 91 745.63.56 dal 14.10.1995
  12.  
  13.  
  14.   Ogni idea e suggerimento sono ben accetti
  15.  
  16.                            Grazie Paul
  17.  
  18. }
  19.  
  20.  
  21. unit Main;
  22.  
  23. interface
  24.  
  25. uses
  26.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  27.   Forms, Dialogs, ExtCtrls;
  28.  
  29. type
  30.   TForm1 = class(TForm)
  31.     Pb: TPaintBox;
  32.     Timer1: TTimer;
  33.     procedure PbPaint(Sender: TObject);
  34.     procedure FormResize(Sender: TObject);
  35.   private
  36.     { Private declarations }
  37.   public
  38.     { Public declarations }
  39.   end;
  40.  
  41. var
  42.   Form1: TForm1;
  43.  
  44. implementation
  45.  
  46. {$R *.DFM}
  47.  
  48. procedure TForm1.PbPaint(Sender: TObject);
  49. var ct : integer;
  50.     cx, cy : integer;
  51.     x1, y1, x2, y2, x3, y3, x4, y4 : integer;
  52.     r, r1, a, b : real;
  53.     angle : real;
  54.     Hour, Min, Sec, MSec : Word;
  55. begin
  56.    Pb.Canvas.Brush.Color := clBlack;
  57.    Pb.Canvas.Rectangle(0,0,Clientwidth,ClientHeight);
  58.    cx := ClientWidth div 2;
  59.    cy := ClientHeight div 2;
  60.    x1 := ClientWidth div 15 ;
  61.    x2 := ClientWidth - ( ClientWidth div 15 );
  62.    y1 := ClientHeight div 15 ;
  63.    y2 := ClientHeight - ( ClientHeight div 15 );
  64.    r  := (x2 - y1) div 2;
  65.    ct := 0;
  66.    for ct := 0 to 11 do
  67.    begin
  68.       case ct of
  69.         0:  Pb.Canvas.Brush.Color := clYellow;
  70.         1:  Pb.Canvas.Brush.Color := 33023;
  71.         2:  Pb.Canvas.Brush.Color := 16744703;
  72.         3:  Pb.Canvas.Brush.Color := clRed;
  73.         4:  Pb.Canvas.Brush.Color := clFuchsia;
  74.         5:  Pb.Canvas.Brush.Color := clPurple;
  75.         6:  Pb.Canvas.Brush.Color := clNavy;
  76.         7:  Pb.Canvas.Brush.Color := clGreen;
  77.         8:  Pb.Canvas.Brush.Color := clTeal;
  78.         9:  Pb.Canvas.Brush.Color := clMaroon;
  79.         10: Pb.Canvas.Brush.Color := 8700415;
  80.         11: Pb.Canvas.Brush.Color := 4567505;
  81.       end;
  82.       angle := (360 -(ct * 30 +196)) * pi / 180;
  83.       a := sin(angle) * r;
  84.       b := cos(angle) * r;
  85.       x3 := cx + round(a);
  86.       y3 := cy + round(b);
  87.       angle := (360 -(ct * 30 +165)) * pi / 180;
  88.       a := sin(angle) * r;
  89.       b := cos(angle) * r;
  90.       x4 := cx + round(a);
  91.       y4 := cy + round(b);
  92.       Pb.Canvas.Pie(X1,Y1,X2,Y2,X3,Y3,X4,Y4);
  93.    end;
  94.    { disegno l'ora }
  95.    x1 := ClientWidth div 11 ;
  96.    x2 := ClientWidth - ( ClientWidth div 11 );
  97.    y1 := ClientHeight div 11 ;
  98.    y2 := ClientHeight - ( ClientHeight div 11 );
  99.    r  := (x2 - y1) div 2;
  100.    Pb.Canvas.Brush.Color := clBlack;
  101.    DecodeTime(Now,Hour,Min,Sec,MSec);
  102.    angle := (360 - (Hour * 30 + Min * 0.5  +166)) * Pi / 180;
  103.    a := sin(angle) * r;
  104.    b := cos(angle) * r;
  105.    x3 := cx + round(a);
  106.    y3 := cy + round(b);
  107.    angle := (360 - (Hour * 30 + Min * 0.5 +195)) * Pi / 180;
  108.    a := sin(angle) * r;
  109.    b := cos(angle) * r;
  110.    x4 := cx + round(a);
  111.    y4 := cy + round(b);
  112.    Pb.Canvas.Pie(X1,Y1,X2,Y2,X3,Y3,X4,Y4);
  113.  
  114. end;
  115.  
  116. procedure TForm1.FormResize(Sender: TObject);
  117. begin
  118.    form1.ClientHeight := ClientWidth;
  119. end;
  120.  
  121. end.
  122.